// pages/member-freezeGold/member-freezeGold.js
import api from '../../utils/api.js'
let app = getApp();
import { HTTP } from '../../utils/http.js'
import { config } from '../../utils/config'
let http = new HTTP()
Page({
    data: {
        // 此页面 页面内容距最顶部的距离
        height: app.globalData.height * 2 + 20,
        showModel: false, // 模态窗口
        showDetail: false, //展示 规则
        currentTab: 0,
        shopList: [],
        imgUrl: config.imgUrl,
        shopNone: false //该用户还没推荐的商家
    },
    bindChange(e) {
        let index = e.currentTarget.dataset.index;
        this.setData({
            currentTab: index
        });
    },
    // 展示规则
    showDetail(e) {
        let showDetail = this.data.showDetail;
        let showModel = this.data.showModel;

        this.setData({
            showDetail: !showDetail,
            showModel: !showModel
        })

    },
    close(e) {
        this.setData({
            showDetail: false,
            showModel: false
        })
    },
    onLoad: function (options) {
        let freeze_gold_gebi = options.freeze_gold_gebi;
        this.setData({
            freeze_gold_gebi
        })
        let user_id = wx.getStorageSync('user_id');
        this.getCateShops(user_id);
    },
    //拿到用户的推荐的商家列表
    //"status": 2  //0审核中1审核不通过2审核通过
    getCateShops(id) {
        http.request({
            url: api.getCateShops,
            data: {
                id: 3
            },
            success: (res) => {
                console.log('拿到用户的推荐的商家列表', res)
                if (res.code == 200) {
                    // silver_coin_nun大于100时， 即解冻， 其值变为 已解冻
                    res.data.forEach((ele) => {
                        console.log('ssssssss', ele.silver_coin_nun)
                        console.log('ssssssss', typeof ele.silver_coin_nun)
                        if (typeof ele.silver_coin_nun == 'number') {
                            ele.number = true
                        } else if (typeof ele.silver_coin_nun == 'string') {
                            ele.number = false // 已解冻
                        }
                    })

                    this.setData({
                        shopList: res.data
                    })


                } else if (res.error_code == 40001) {
                    this.setData({
                        shopNone: true
                    })
                }
            }
        })
    },

    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },
    onPullDownRefresh: function () {

    },
    onReachBottom: function () {

    }
})